'use strict';

const Service = require('egg').Service;

class HomeService extends Service {
  async put(title,timer,status,important,readnum,author) {
        return await this.app.mysql.query('insert into list (title,create_time,status,important,readnum,author) values (?,?,?,?,?,?)',[title,timer,status,important,readnum,author])
  }

  async update(title,timer,status,important,readnum,author,id) {
    return await this.app.mysql.query('update list set title=?,create_time=?,status=?,important=?,readnum=?,author=? where id=?',[title,timer,status,important,readnum,author,id])
    }

    async bookslist(start,limit){
        return await this.app.mysql.query(`select * from list limit ${start},${limit}`)
    }

    async total(){
        return await this.app.mysql.query('select count(*) from list');
    }

    async del(id){
        return await this.app.mysql.query('delete from list where id=?',[id])
    }
}

module.exports = HomeService;
